using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace WIT.DAQ.Core.Forms.UserControls;

/// <summary>
///
/// </summary>
internal class UC_DAQItemParams_For_S7 : UserControl
{
	/// <summary>
	/// 地址
	/// </summary>
	internal string ADDRESS = string.Empty;

	/// <summary> 
	/// 必需的设计器变量。
	/// </summary>
	private IContainer components = null;

	private Label label1;

	private TextBox txtAddress;

	private Label label2;

	private Label label3;

	/// <summary>
	///
	/// </summary>
	internal UC_DAQItemParams_For_S7()
	{
		InitializeComponent();
	}

	/// <summary>
	///
	/// </summary>
	/// <param name="address"></param>
	internal UC_DAQItemParams_For_S7(string address)
	{
		InitializeComponent();
		ADDRESS = address;
		txtAddress.Text = ADDRESS;
	}

	/// <summary>
	/// 校验输入的内容是否合法
	/// </summary>
	/// <returns></returns>
	internal bool ValidateInputs(out string msg)
	{
		msg = string.Empty;
		bool flag = false;
		try
		{
			ADDRESS = txtAddress.Text.Trim();
			if (string.IsNullOrEmpty(ADDRESS))
			{
				throw new Exception("请输入正确的地址");
			}
			flag = true;
		}
		catch (Exception ex)
		{
			flag = false;
			msg = ex.Message;
		}
		return flag;
	}

	/// <summary> 
	/// 清理所有正在使用的资源。
	/// </summary>
	/// <param name="disposing">如果应释放托管资源，为 true；否则为 false。</param>
	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	/// <summary> 
	/// 设计器支持所需的方法 - 不要修改
	/// 使用代码编辑器修改此方法的内容。
	/// </summary>
	private void InitializeComponent()
	{
		this.label1 = new System.Windows.Forms.Label();
		this.txtAddress = new System.Windows.Forms.TextBox();
		this.label2 = new System.Windows.Forms.Label();
		this.label3 = new System.Windows.Forms.Label();
		base.SuspendLayout();
		this.label1.AutoSize = true;
		this.label1.ForeColor = System.Drawing.Color.Red;
		this.label1.Location = new System.Drawing.Point(238, 38);
		this.label1.Name = "label1";
		this.label1.Size = new System.Drawing.Size(17, 12);
		this.label1.TabIndex = 30;
		this.label1.Text = "* ";
		this.txtAddress.Location = new System.Drawing.Point(111, 35);
		this.txtAddress.Name = "txtAddress";
		this.txtAddress.Size = new System.Drawing.Size(121, 21);
		this.txtAddress.TabIndex = 0;
		this.label2.AutoSize = true;
		this.label2.Location = new System.Drawing.Point(52, 38);
		this.label2.Name = "label2";
		this.label2.Size = new System.Drawing.Size(53, 12);
		this.label2.TabIndex = 29;
		this.label2.Text = "Address:";
		this.label3.AutoSize = true;
		this.label3.ForeColor = System.Drawing.SystemColors.ControlText;
		this.label3.Location = new System.Drawing.Point(109, 59);
		this.label3.Name = "label3";
		this.label3.Size = new System.Drawing.Size(227, 12);
		this.label3.TabIndex = 31;
		this.label3.Text = "例：DB100.20,M100,I100,Q100,T100,C100";
		base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.Controls.Add(this.label3);
		base.Controls.Add(this.label1);
		base.Controls.Add(this.txtAddress);
		base.Controls.Add(this.label2);
		base.Name = "UC_DAQItemParams_For_S7";
		base.Size = new System.Drawing.Size(523, 163);
		base.ResumeLayout(false);
		base.PerformLayout();
	}
}
